// pages/index/Specialcolumn.js
import regeneratorRuntime from '../../utils/regenerator-runtime/runtime-module';

const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        commonImgUrl: '',//全局图片网络路径
        originalList: [],//原始专栏列表
        specialList: [],//当前分类对应的专栏列表
        tabList: [],
        currentTabID: '',
        nowPage: 1,//当前页
        pageShow: 10,//每页展示数量
        hasMoreData: true,
    },

    /**
     * @author 焦政
     * @Description: 专栏列表展示
     */
    async getContentList(customerUuid = '') {
        var opionss = {
            data: {
                customerUuid: customerUuid,
                nowPage: this.data.nowPage,
                pageShow: this.data.pageShow
            }
        }
        let resContentList = await app.$net.post('getContentList', 1, opionss, 'wxshop')
        console.log(resContentList.data.linkmap)
        let list = []
        for (let key in resContentList.data.linkmap) {
            list.push({'customerUuid': key, 'label': resContentList.data.linkmap[key]})
        }
        this.setData({
            originalList: resContentList.data.contentList,
            tabList: list,
            currentTabID: list[0].customerUuid
        })
        let arr = []
        resContentList.data.contentList.forEach(item => {
            if (item.customerUuid == list[0].customerUuid) {
                arr.push(item)
            }
        })
        this.setData({
            specialList:arr
        })
        console.log(this.data.specialList)
    },
    /**
     * @author 焦政
     * @Description: 选择tab
    */
    e_seletab(e){
        let arr = []
        this.data.originalList.forEach(item=>{
            if(item.contentCategoryUuid == e.currentTarget.dataset.customeruuid){
                arr.push(item)
            }
        })
        this.setData({
            specialList:arr,
            currentTabID:e.currentTarget.dataset.customeruuid
        })
        console.log(this.data.specialList)
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        //配置全局图片网络路径
        this.setData({
            commonImgUrl: app.$imgURL
        })
        this.getContentList()
    },

    //页面跳转
    go(e) {
        console.log(e)
        wx.navigateTo({
            url: 'Columndetails?speciaID='+e.currentTarget.dataset.specialid
        })
    },


    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

})